<?php

class os{

    function set_page($new_page){
        $this->pageid = $new_page;
        return $this->pageid;
    }

    function set_os($new_os){
        $this->os = $new_os;
        return $this->os;
    }

    function get_osname(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT osname FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->osname = $row->osname;
        return $this->osname;
        $query->close();
        $connect->close();
    }

    function get_summary(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT summary FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->summary = $row->summary;
        return $this->summary;
        $query->close();
        $connect->close();
    }

    function get_history(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT history FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->history = $row->history;
        return $this->history;
        $query->close();
        $connect->close();
    }

    function get_kernelName(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT kernel_name FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->kernelName = $row->kernel_name;
        return $this->kernelName;
        $query->close();
        $connect->close();
    }

    function get_kernelType(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT kernel_type FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->kernelType = $row->kernel_type;
        return $this->kernelType;
        $query->close();
        $connect->close();
    }

    function get_fileSystem(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT filesys FROM ".$prefix."os WHERE osname = '".$this->os."'");
        $row = $query->fetch_object();
        $this->fileSystem = $row->filesys;
        return $this->fileSystem;
        $query->close();
        $connect->close();
    }

    function get_distros(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT distros FROM ".$prefix."os WHERE osname = '".$this->os."' LIMIT 5");
            $row = $query->fetch_object();
            if(!empty($row->distros)){
                $this->distList = explode(', ', $row->distros);
                return $this->distList;
                $result->close();
            }
            else{
                return "";
            }
    }

    function get_similar(){
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT osname FROM ".$prefix."os WHERE kernel_name LIKE '%".$this->kernelName."%' AND kernel_type LIKE '".$this->kernelType."'");
        while($row = $query->fetch_object()){
            $this->similarOs[] = array(
                "osname" => $row->osname
            );
        }
        return $this->similarOs;
        $query->close();
        $connect->close();
    }
}
?>
